<?php
/**
 * 
 * @author Paolo Bertuzzo
 *
 */
namespace Catalog\Data;

class ProductImageDao extends AbstractDao
{
    
    /**
     * 
     * @param int $productId
     * @param string $language
     */
    public function get($productId, $language)
    {
        $query = $this->entityManager->createQuery('select pi from Catalog\Entity\ProductImage pi ' .
        		'where pi.productId = ?1 and pi.language = ?2');
        
        $query->setParameter(1, $productId);
        $query->setParameter(2, $language);
        $query->useResultCache(true);
        
        return $query->getResult();
    }
    
    /**
     *
     * @param int $productId
     * @param string $language
     * @param string $type
     */
    public function getByType($productId, $language, $type)
    {
    	$query = $this->entityManager->createQuery('select pi from Catalog\Entity\ProductImage pi ' .
    			'where pi.productId = ?1 and pi.language = ?2 and pi.type = ?3');
    
    	$query->setParameter(1, $productId);
    	$query->setParameter(2, $language);
    	$query->setParameter(3, $type);
    	$query->useResultCache(true);
    
    	return $query->getResult();
    }
    
}

?>